<template>
	<div>
		<h1>付款</h1>
		<el-form label-width="80px">
			<el-form-item label="订当号:">
				<el-input v-model="user.ordid"></el-input>
			</el-form-item>
			<el-form-item label="订当总额:">
				<el-input v-model="user.amount"></el-input>
			</el-form-item>
			<el-form-item label="姓名:">
				<el-input v-model="user.ship2name"></el-input>
			</el-form-item>

			<el-form-item label="电话:">
				<el-input v-model="user.ship2phone"></el-input>
			</el-form-item>
			<el-form-item label="地址:">
				<el-input v-model="user.ship2addr"></el-input>
			</el-form-item>
			<el-form-item label="付款状态:">
				<el-button v-show="!judge" style="background-color: orangered;color:white;font-family: KaiTi;"
					@click="fk()">未付款(点击付款)</el-button>
				<el-button v-show="judge" style="font-family: KaiTi;background-color: lightgreen;">已付款</el-button>
			</el-form-item>
		</el-form>
		<el-table :data="list" border style="width: 43.1%;text-align: center;">
			<el-table-column label="图片" width="120">
				<template slot-scope="scope">
					<img :src="`${$ip}/api/public/showimg/${scope.row.book.pic}`" min-width="20" height="70"
						style="height: 50PX;width: 80px;" />
				</template>
			</el-table-column>
			<el-table-column prop="book.name" label="商品名称" width="200">
			</el-table-column>
			<el-table-column prop="price" label="商品价格" width="120">
			</el-table-column>
			<el-table-column sortable prop="num" label="商品数量" width="120">
			</el-table-column>
			<el-table-column sortable prop="z" label="商品总价" width="120">
			</el-table-column>
			<el-table-column prop="book.stock" label="商品库存" width="125">
			</el-table-column>

		</el-table>
	</div>
</template>

<script>
	export default {
		name: 'pcdoOrder',
		data() {
			return {
				user: {},
				judge: false,
				list: [],
				img: '',
				zj: ''
			}
		},
		methods: {
			fk() {
				this.judge = true;
				this.$postkv('/api/fore/ord/addPay/' + this.user.ordid).then((resp) => {
					console.log(resp.data.data);
				});
				this.$get('/api/fore/ord/findByOrdid/' + this.user.ordid).then((resp) => {
					console.log(resp.data.data);
					this.$message({
						showClose: true,
						message: '付款成功,等待商家发货'
					});
				})
			},

		},
		mounted() {
			console.log(100);
			console.log(this.$route.query.dx);
			console.log(this.$route.query.dx.od);
			this.$get('/api/fore/ord/findByOrdid/' + this.$route.query.dx.od).then((resp) => {
				this.user = resp.data.data;
				let k = resp.data.data.items;
				console.log(resp.data.data.items);
				for (let i in k) {
					console.log(k[i]);

					this.list.push(k[i]);
				}
				this.list.forEach((item) => {
					item.z = item.price * item.num;
				})
				console.log("提交订当后获取的商品信息" + resp.data.data.book);
				if (resp.data.data.payStatus > 0) {
					this.judge = false;
				}
				console.log(this.list);
			})
		}
	}
</script>

<style>

</style>